package day16;

public class learn3 implements  Runnable {
    public static void main(String[] args) {
        learn3 learn3 = new learn3();
    Thread thread6=new Thread(learn3,"子线程");
    thread6.start();
    try{
        Thread.yield();
    }catch (Exception e){
        e.printStackTrace();
    }
    //主线程循环15次
    for(int i=0;i<15;i++){
        if(i%5==0){
            try{
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println(Thread.currentThread().getName()+"第"+(i+1)+"次");
    }
    }
    @Override
    public void run() {
        for(int i=0;i<9;i++){
            if(i%3==0){
                try{
                    Thread.sleep(50);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(Thread.currentThread().getName()+"第"+(i+1)+"次");
        }

    }
}
